# Dreams have to come true after all
from datetime import datetime

from sqlalchemy import ForeignKey  #

from comment import db


class Letter(db.Model):
    __tablename__ = 'letter'
    id = db.Column(db.Integer, primary_key=True, autoincrement=True)
    sendID = db.Column(db.String(64), doc='发送者姓名')
    recID = db.Column(db.BIGINT, doc='接收者ID')
    detail_id = db.Column(db.BIGINT, ForeignKey('t_letter_detail.id'), doc='消息详情主键')
    letter_detail = db.relationship('Letter_detail', backref=db.backref('letter', lazy=True))
    state = db.Column(db.Integer, doc='持否已读（0未读；1已读）')


# 站内信详情的模型类
class Letter_detail(db.Model):
    __tablename__ = 't_letter_detail'
    id = db.Column(db.BIGINT, primary_key=True, autoincrement=True)
    title = db.Column(db.String(256), doc='标题')
    detail = db.Column(db.String(256), doc='消息内容')
    pDate = db.Column(db.DateTime, default=datetime.now(), doc='发送时间')
